package gui;

import java.io.File;

import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Dialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;

import resources.images.ImagesPath;

public class MissionDialog extends Dialog {

	protected Object result;
	protected Shell shell;
	
	private String mission;

	/**
	 * Create the dialog
	 * @param parent
	 * @param style
	 */
	public MissionDialog(Shell parent, int style) {
		super(parent, style);
	}

	/**
	 * Create the dialog
	 * @param parent
	 */
	public MissionDialog(Shell parent) {
		this(parent, SWT.NONE);
	}
	
	public MissionDialog(String mission, Shell parent) {
		this(parent, SWT.NONE);
		this.mission = mission;
	}

	/**
	 * Open the dialog
	 * @return the result
	 */
	public Object open() {
		createContents();
		shell.open();
		shell.layout();
		Display display = getParent().getDisplay();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}
		return result;
	}

	/**
	 * Create contents of the dialog
	 */
	protected void createContents() {
		shell = new Shell(getParent(), SWT.APPLICATION_MODAL | SWT.TITLE | SWT.BORDER | SWT.CLOSE);
		shell.setLocation(RiskGUI.getNewPosition(getParent()));
		shell.setSize(400, 540);
		shell.setText("Your Mission");
		Composite composite = new Composite(shell, SWT.NONE);
		composite.setSize(400, 512);
		composite.setBackgroundImage(Images.getImage("mission.png"));
		composite.setBackgroundMode(SWT.INHERIT_DEFAULT);
		Label textLabel = new Label(composite, SWT.WRAP);
		textLabel.setBounds(30, 80, 340, 350);
		textLabel.setAlignment(SWT.CENTER);
		String separator = File.separator;
//		TODO Font font = FontLoader.loadFont(
//				shell, 
//				"src" + separator + "resources" + separator + "fonts" + separator + "papyrus.ttf", 
//				14);
//		textLabel.setFont(font);
//		textLabel.setFont(SWTResourceManager.getFont("Papyrus", 14, SWT.NONE));
		textLabel.setText(mission);
		//
	}
}
